#include <stdio.h>

int mySqrt(int x) 
{
	int left = 0;
	int right = x;
	int mid = left + (right - left) / 2;
	int ans = -1;

	while (left <= right)
	{
		mid = left + (right - left) / 2;
		if ((long long)mid * mid <= x )
		{
			left = mid + 1;
			ans = mid;
		}
		else if (mid * mid > x )
		{
			right = mid - 1;
		}
	}
	return ans;
}

int main()
{
	printf("%d\n", mySqrt(10));
	return 0;
}
